package total;

import java.util.Scanner;

public class Ques1774 {
	
	public void go(){
		Scanner scan = new Scanner(System.in);
		int n,k,p;
		int cnt,value,now,ans;
		int[] a,b,c;
		while(scan.hasNext()){
			now = 0;
			ans = 0;
			n = scan.nextInt();
			k = scan.nextInt();
			p = scan.nextInt();
			a = new int[200];
			b = new int[200];
			c = new int[200];
			for (int i = 1; i <= n; i++) {
				cnt = scan.nextInt();
				value = scan.nextInt();
				if(value <= p){
					now = i;
				}
				if(a[cnt]<=now){
					b[cnt]=c[cnt];  					
				}
			        ans+=b[cnt];  
			        c[cnt]++;  
			        a[cnt]=i;
			}
			System.out.println(ans);
		}
	}
	
	public static void main(String[] args) {
		new Ques1774().go();
	}
}	
